<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
// +----------------------------------------------------------------------

namespace Card\Model;
use Think\Model;

/**
 * 手机验证码模型
 * @author 麦当苗儿 <zuojiazi@vip.qq.com>
 */

class SmsLogModel extends Model {

    public $sx_data = array();

    /**
     * 增加短信记录
     */
    public function addSms($log_array) {
        // var_dump($log_array);

        $res = $this->add($log_array);
        // var_dump($res);exit;
        // return $res;

    }
    /**
     * 修改短信记录
     */
    public function saveSms($data) {
        $wh['log_phone'] = $data['log_phone'];
        //查id
        $id = $this->where($wh)->field('id')->order('add_time desc,id desc')->find();
        $sms_data['is_use'] = $data['is_use'];

        $res = $this->where($id)->save($sms_data);
        // var_dump($res);exit;
        return $res;

    }

    /**
     * 查询单条记录
     */
    public function getSmsInfo($condition) {
    
        if(!$condition){
            return false;
        }
        // var_dump($this->data);
        $res = $this->where($condition)->order('add_time desc,id desc')->find();
        return $res;

    }

    /**
     * 查询记录
     *
     */
    public function getSmsList($condition = array(), $page = '', $limit = '', $order = 'id desc') {
        $result = $this->where($condition)->page($page)->limit($limit)->order($order)->select();
        return $result;
    }

    /**
     * 取得记录数量
     *
     */
    public function getSmsCount($condition) {
        return $this->where($condition)->count();
    }   

}
